﻿using Mathmall.Administration.Models;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace Mathmall.Administration.Data
{
    public class ProductAttrValueEntityTypeConfiguration : IEntityTypeConfiguration<ProductAttrValue>
    {
        public void Configure(EntityTypeBuilder<ProductAttrValue> builder)
        {
            // 不使用output子句
            builder.ToTable(table => table.UseSqlOutputClause(false));

            builder
                .ToTable(nameof(ProductAttrValue))
                .ToTable(tableBuilder => tableBuilder.HasComment("spu属性值"));

            builder
                .HasKey(productAttrValue => productAttrValue.ProductAttrValueID)
                .HasName("ProductAttrValueID");

            builder
                .Property(productAttrValue => productAttrValue.SpuID)
                .HasColumnName("SpuID")
                .HasColumnType("int")
                .HasComment("商品id")
                .IsRequired(false);

            builder
                .Property(productAttrValue => productAttrValue.AttrID)
                .HasColumnName("AttrID")
                .HasColumnType("int")
                .HasComment("属性id")
                .IsRequired(false);

            builder
                .Property(productAttrValue => productAttrValue.AttrName)
                .HasColumnName("AttrName")
                .HasColumnType("nvarchar(200)")
                .HasComment("属性名")
                .IsRequired(false);

            builder
                .Property(productAttrValue => productAttrValue.AttrValue)
                .HasColumnName("AttrValue")
                .HasColumnType("nvarchar(200)")
                .HasComment("属性值")
                .IsRequired(false);

            builder
                .Property(productAttrValue => productAttrValue.AttrSort)
                .HasColumnName("AttrSort")
                .HasColumnType("int")
                .HasComment("顺序")
                .IsRequired(false);

            builder
                .Property(productAttrValue => productAttrValue.QuickShow)
                .HasColumnName("QuickShow")
                .HasColumnType("tinyint")
                .HasComment("快速展示【是否展示在介绍上；0-否 1-是】")
                .IsRequired(false);

            builder
                .Property(productAttrValue => productAttrValue.CreateTime)
                .HasColumnName("CreateTime")
                .HasColumnType("datetime")
                .HasComment("创建时间")
                .IsRequired(false);

            builder
                .Property(productAttrValue => productAttrValue.LastUpdateTime)
                .HasColumnName("LastUpdateTime")
                .HasColumnType("datetime")
                .HasComment("最后更新时间")
                .IsRequired(false);
        }
    }
}
